home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 2 / MacMania 2.toast / Demo's / Tools&Utilities / Programming / CIncludesTool / modified version / put in scripts folder / OMCIncludesTool < prev   
Encoding:
Text File  |  1994-02-27  |  10.4 KB  |  370 lines  |  [TEXT/BROW]

  1. # Script For CIncludes Tool - by John Jeppson
  2. # modified for use with ObjectMaster
  3.  
  4. Set Exit 0
  5. Set param 0
  6. Set toolStatus 0
  7.  
  8. If {#} == 1
  9.     If ("{1}" == "-m") || ("{1}" == "-M")
  10.         Set param 1
  11.     Else If ("{1}" == "-f") || ("{1}" == "-F")
  12.         Set param 2
  13.     Else If ("{1}" == "-i") || ("{1}" == "-I")
  14.         Set param 3
  15.     Else If ("{1}" == "-d") || ("{1}" == "-D")    # Daniel Grassi
  16.         Set param 4
  17.     End
  18. End
  19.  
  20. If {param} == 0
  21.     OMAlert "OMCIncludesTool - Usage :CIncludesTool [-f -m -i -d]∂n ∂
  22.    -f  Locates selection from active window∂n ∂
  23.    -m  Rebuilds the CIncludes identifier dictionary∂n ∂
  24.    -i  Reformats ∂"#include∂" statements in selection∂n ∂
  25.    -d  Displays the file declaring the selection"
  26.  
  27. Else If {param} == 1
  28. ##    Find §:/∞/ "{Active}"
  29. ##    Find §Δ "{Active}"
  30. ##    Echo
  31.  
  32.     If ("{CIncludesCompiler}" == 'AppleCFront')
  33.         Set j "`Quote "{CIncludes}"`≈.h"
  34.         Begin
  35.             Set SrchList ""
  36.             Set j "`Quote "{CIncludes}"`≈.h"
  37.             If ("`Exists -f {j}`" != "")
  38.                 Set SrchList "`Quote "{CIncludes}"`≈.h"
  39.             Else
  40.                 Set SrchList ""
  41.             End  # If Exists
  42.         End ≥ Dev:Null
  43.         For j in `Files -fr -d -r -o "{CIncludes}"`
  44.             If ("`Exists -f "{j}"≈.h`" != "")
  45.                 Set j "`Quote "{j}"`"
  46.                 Set SrchList "{SrchList} {j}≈.h"
  47.             End  # If Exists
  48.         End ∑ Dev:Null # For j
  49.         If ({MACPlusIncludes} != "")
  50.             Begin
  51.                 Set SrchList2 ""
  52.                 Set j "`Quote "{MACPlusIncludes}"`≈.h"
  53.                 If ("`Exists -f {j}`" != "")
  54.                     Set SrchList2 "`Quote "{MaCPLusIncludes}"`≈.h"
  55.                 Else
  56.                     Set SrchList2 ""
  57.                 End  # If Exists
  58.             End ≥ Dev:Null
  59.             For j in `Files -fr -d -r -o "{MACPlusIncludes}"`
  60.                 If ("`Exists -f "{j}"≈.h`" != "")
  61.                     Set j "`Quote "{j}"`"
  62.                     Set SrchList2 "{SrchList2} {j}≈.h"
  63.                 End  # If Exists
  64.             End  ∑ Dev:Null # For j
  65.             CIncludesCode -m `Files -fr {SrchList} {SrchList2}`
  66.             Unset SrchList2
  67.         Else
  68.             CIncludesCode -m `Files -fr {SrchList}`
  69.         End  # If
  70.     Else
  71.         If ("{CIncludesCompiler}" == 'SymantecC++')
  72.             Begin
  73.                 Set SrchList ""
  74.                 Set j "`Quote "{SCIncludes}"`≈.h"
  75.                 If ("`Exists -f {j}`" != "")
  76.                     Set SrchList "`Quote "{SCIncludes}"`≈.h"
  77.                 Else
  78.                     Set SrchList ""
  79.                 End  # If Exists
  80.             End ≥ Dev:Null
  81.             For j in `Files -fr -d -r -o "{SCIncludes}"`
  82.                 If ("`Exists -f "{j}"≈.h`" != "")
  83.                     Set j "`Quote "{j}"`"
  84.                     Set SrchList "{SrchList} {j}≈.h"
  85.                 End  # If Exists
  86.             End ∑ Dev:Null # For j
  87.             If ({MASCPlusIncludes} != "")
  88.                 Begin
  89.                     Set SrchList2 ""
  90.                     Set j "`Quote "{MASCPlusIncludes}"`≈.h"
  91.                     If ("`Exists -f {j}`" != "")
  92.                         Set SrchList2 "`Quote "{MASCPlusIncludes}"`≈.h"
  93.                     Else
  94.                         Set SrchList2 ""
  95.                     End  # If Exists
  96.                 End ≥ Dev:Null
  97.                 For j in `Files -fr -d -r -o "{MASCPlusIncludes}"`
  98.                     If ("`Exists -f "{j}"≈.h`" != "")
  99.                         Set j "`Quote "{j}"`"
  100.                         Set SrchList2 "{SrchList2} {j}≈.h"
  101.                     End  # If Exists
  102.                 End  ∑ Dev:Null # For j
  103.                 CIncludesCode -m `Files -fr {SrchList} {SrchList2}`
  104.                 Unset SrchList2
  105.             Else
  106.                 CIncludesCode -m `Files -fr {SrchList}`
  107.             End  # If
  108.         Else
  109.             If ("{CIncludesCompiler}" == 'MetrowerksC++')
  110.                 Begin
  111.                     Set SrchList ""
  112.                     Set j "`Quote "{MWIncludes}"`≈.h"
  113.                     If ("`Exists -f {j}`" != "")
  114.                         Set SrchList "`Quote "{MWIncludes}"`≈.h"
  115.                     Else
  116.                         Set SrchList ""
  117.                     End  # If Exists
  118.                 End ≥ Dev:Null
  119.                 For j in `Files -fr -d -r -o "{MWIncludes}"`
  120.                     If ("`Exists -f "{j}"≈.h`" != "")
  121.                         Set j "`Quote "{j}"`"
  122.                         Set SrchList "{SrchList} {j}≈.h"
  123.                     End  # If Exists
  124.                 End ∑ Dev:Null # For j
  125.                 If ({MAMCPlusIncludes} != "")
  126.                     Set j "`Quote "{MAMCPlusIncludes}"`≈.h"
  127.                         Begin
  128.                             Set SrchList2 ""
  129.                             Set j "`Quote "{MAMCPlusIncludes}"`≈.h"
  130.                             If ("`Exists -f {j}`" != "")
  131.                                 Set SrchList2 "`Quote "{MAMCPlusIncludes}"`≈.h"
  132.                             Else
  133.                                 Set SrchList2 ""
  134.                             End  # If Exists
  135.                         End ≥ Dev:Null
  136.                     For j in `Files -fr -d -r -o "{MAMCPlusIncludes}"`
  137.                         If ("`Exists -f "{j}"≈.h`" != "")
  138.                             Set j "`Quote "{j}"`"
  139.                             Set SrchList2 "{SrchList2} {j}≈.h"
  140.                         End  # If Exists
  141.                     End  ∑ Dev:Null # For j
  142.                     CIncludesCode -m `Files -fr {SrchList} {SrchList2}`
  143.                     Unset SrchList2
  144.                 Else
  145.                     CIncludesCode -m `Files -fr {SrchList}`
  146.                 End  # If
  147.             End  # If
  148.         End  # If
  149.     End  # If
  150.  
  151.     Unset SrchList
  152.     Set toolStatus "{Status}"
  153.     Beep 2C,20,128
  154.  
  155. Else If {param} == 2
  156. ##    Mark -y § x162534 "{Active}"
  157.  
  158.     Set str "`OM_SendAE GSEL %Text`"
  159.     CIncludesCode -v "{str}"
  160.     Set toolStatus "{Status}"
  161.  
  162.     If {toolStatus} == 0
  163. ##        Find • "{Active}"
  164. ##       Find Δ/#include/ "{Active}"                  # Daniel Grassi
  165. ##        CIncludesCode -f "{str}"
  166. ##        Set toolStatus "{Status}"
  167. ## replacement (different functionality) from above
  168.     Set counter 1
  169.     For i in `CIncludesCode -d "{str}"`
  170.         If {counter} == 1
  171.             OMAlert "Header file is {i}"
  172.             Set counter 2
  173.         End  # If {counter}
  174.     End  # For i
  175. End  # If {ToolStatus}
  176.     
  177. ##    Find x162534 "{Active}"
  178. ##    Unmark x162534 "{Active}"
  179.  
  180. Else If {param} == 3
  181. ##    CIncludesCode -i "{Active}.§"
  182. ##    Set toolStatus "{Status}"
  183.     OMAlert "{0} :∂n∂noption -i (reformating selected include statements) is not supported in ObjectMaster."
  184.  
  185. Else If {param} == 4                                # Daniel Grassi
  186.         Set str "`OM_SendAE GSEL %Text`"
  187.         CIncludesCode -v "{str}"
  188.         Set toolStatus "{Status}"
  189.  
  190.         If {toolStatus} == 0
  191.             Set counter 1
  192.             For i in `CIncludesCode -d "{str}"`
  193.                 If {counter} == 1
  194.                 
  195.                     If ("{CIncludesCompiler}" == 'AppleCFront')
  196.                         Set SrchList "`Quote "{CIncludes}{i}"`"
  197.                         For j in `Files -fr -d -r "{CIncludes}"`
  198.                             Set j "`Quote "{j}"`"
  199.                             Set SrchList "{SrchList} {j}{i}"
  200.                         End ∑ Dev:Null # For j
  201.                         
  202.                         For j in {SrchList}
  203. ##                            Open -r "{j}" ∑∑ Dev:Null
  204.                             Set j "`Quote "{j}"`"
  205.                             If ("`Exists -f {j}`" != "")
  206.                                 OM_SendAE LINE -FILEalis {j}
  207.                                 If ({Status} == 0)
  208.                                     Set FoundIt 1
  209.                                     Set HeaderName "{j}"
  210.                                     Break
  211.                                 End  # If {Status}
  212.                             End  # If Exists
  213.                         End ∑ Dev:Null # For j
  214.                         Unset SrchList
  215.     
  216.                         If ({FoundIt} == 0)
  217.                             Set SrchList "`Quote "{MACPlusIncludes}{i}"`"
  218.                             For j in `Files -fr -d -r "{MACPlusIncludes}"`
  219.                                 Set j "`Quote "{j}"`"
  220.                                 Set SrchList "{SrchList} {j}{i}"
  221.                             End ∑ Dev:Null # For j
  222.                             For j in {SrchList}
  223. ##                                Open -r "{j}" ∑∑ Dev:Null
  224.                                 Set j "`Quote "{j}"`"
  225.                                 If ("`Exists -f {j}`" != "")
  226.                                     OM_SendAE LINE -FILEalis {j}
  227.                                     If ({Status} == 0)
  228.                                         Set FoundIt 1
  229.                                         Set HeaderName "{j}"
  230.                                         Break
  231.                                     End  # If {Status}
  232.                                 End  # If Exists
  233.                             End ∑ Dev:Null  # For j
  234.                             Unset SrchList
  235.                             If ({FoundIt} == 0)
  236.                                 OMAlert "Unable to open the header file {i}"
  237.                             End  # If {Status}
  238.                         End  # If {Status}
  239.                     Else
  240.                         If ("{CIncludesCompiler}" == 'SymantecC++')
  241.                             Set SrchList "`Quote "{SCIncludes}{i}"`"
  242.                             For j in `Files -fr -d -r "{SCIncludes}"`
  243.                                 Set j "`Quote "{j}"`"
  244.                                 Set SrchList "{SrchList} {j}{i}"
  245.                             End ∑ Dev:Null # For j
  246.                             
  247.                             For j in {SrchList}
  248. ##                                Open -r "{j}" ∑∑ Dev:Null
  249.                                 Set j "`Quote "{j}"`"
  250.                                 If ("`Exists -f {j}`" != "")
  251.                                     OM_SendAE LINE -FILEalis {j}
  252.                                     If ({Status} == 0)
  253.                                         Set FoundIt 1
  254.                                         Set HeaderName "{j}"
  255.                                         Break
  256.                                     End  # If {Status}
  257.                                 End  # If Exists
  258.                             End ∑ Dev:Null # For j
  259.                             Unset SrchList
  260.         
  261.                             If ({FoundIt} == 0)
  262.                                 Set SrchList "`Quote "{MASCPlusIncludes}{i}"`"
  263.                                 For j in `Files -fr -d -r "{MASCPlusIncludes}"`
  264.                                     Set j "`Quote "{j}"`"
  265.                                     Set SrchList "{SrchList} {j}{i}"
  266.                                 End ∑ Dev:Null # For j
  267.                                 For j in {SrchList}
  268. ##                                    Open -r "{j}" ∑∑ Dev:Null
  269.                                     Set j "`Quote "{j}"`"
  270.                                     If ("`Exists -f {j}`" != "")
  271.                                         OM_SendAE LINE -FILEalis {j}
  272.                                         If ({Status} == 0)
  273.                                             Set FoundIt 1
  274.                                             Set HeaderName "{j}"
  275.                                             Break
  276.                                         End  # If {Status}
  277.                                     End  # If Exists
  278.                                 End ∑ Dev:Null  # For j
  279.                                 Unset SrchList
  280.                                 If ({FoundIt} == 0)
  281.                                     OMAlert "Unable to open the header file {i}"
  282.                                 End  # If {Status}
  283.                             End  # If {Status}
  284.                         Else
  285.                             If ("{CIncludesCompiler}" == 'MetrowerksC++')
  286.                                     Set SrchList "`Quote "{MWIncludes}{i}"`"
  287.                                     For j in `Files -fr -d -r "{MWIncludes}"`
  288.                                         Set j "`Quote "{j}"`"
  289.                                         Set SrchList "{SrchList} {j}{i}"
  290.                                     End ∑ Dev:Null # For j
  291.  
  292.                                     For j in {SrchList}
  293. ##                                        Open -r "{j}" ∑∑ Dev:Null
  294.                                         Set j "`Quote "{j}"`"
  295.                                         If ("`Exists -f {j}`" != "")
  296.                                         OM_SendAE LINE -FILEalis {j}
  297.                                             If ({Status} == 0)
  298.                                                 Set FoundIt 1
  299.                                                 Set HeaderName "{j}"
  300.                                                 Break
  301.                                             End  # If {Status}
  302.                                         End  # If Exists
  303.                                     End ∑ Dev:Null # For j
  304.                                     Unset SrchList
  305.                 
  306.                                     If ({FoundIt} == 0)
  307.                                         Set SrchList "`Quote "{MAMCPlusIncludes}{i}"`"
  308.                                         For j in `Files -fr -d -r "{MAMCPlusIncludes}"`
  309.                                             Set j "`Quote "{j}"`"
  310.                                             Set SrchList "{SrchList} {j}{i}"
  311.                                         End ∑ Dev:Null # For j
  312.                                         For j in {SrchList}
  313. ##                                            Open -r "{j}" ∑∑ Dev:Null
  314.                                             Set j "`Quote "{j}"`"
  315.                                             If ("`Exists -f {j}`" != "")
  316.                                                 OM_SendAE LINE -FILEalis {j}
  317.                                                 If ({Status} == 0)
  318.                                                     Set FoundIt 1
  319.                                                     Set HeaderName "{j}"
  320.                                                     Break
  321.                                                 End  # If {Status}
  322.                                             End  # If Exists
  323.                                         End ∑ Dev:Null  # For j
  324.                                         Unset SrchList
  325.                                         If ({FoundIt} == 0)
  326.                                             OMAlert "Unable to open the header file {i}"
  327.                                         End  # If {Status}
  328.                                     End  # If {Status}
  329.                                 End  # If
  330.                             End  # If
  331.                         End  # If
  332.  
  333.                     Set counter 2
  334.                 Else
  335. ##                      Find •!{i} "{Active}"
  336. ##                    Find \{str}\ "{Active}" ∑∑ Dev:Null
  337. ###                    OM_SendAE LINE -OFFSlong "{i}" '-LEN long' 0 -FILEalis "{HeaderName}"
  338.                     Set HeaderName "`Quote {HeaderName}`"
  339.                     Set LineNo "`FilePosToLine {HeaderName} "{i}"`"
  340.                     OM_SendAE LINE -FILEalis {HeaderName} -LINElong {LineNo}
  341.                 End
  342.             End
  343.             If ("{i}" == "")
  344.                 Set toolStatus 4                    # new - signal that no identifiers were found
  345.             Else
  346.                 Set toolStatus "{Status}"
  347.             End  # If {i}
  348.         End
  349. End
  350.  
  351.  
  352. If {toolStatus}
  353.     If {toolStatus} == '1'
  354.         OMAlert 'Bad parameters to "OMCIncludesCode"'    # won't occur here
  355.     Else If {toolStatus} == '2'
  356.         OMAlert 'Invalid Identifier!'
  357.     Else If {toolStatus} == '3'
  358.         If ({param} == 2) || (param} == 3)
  359.             OMAlert 'Unable to load database resource!'
  360.         Else
  361.             OMAlert 'Out of memory error!'
  362.         End
  363.     Else If {toolStatus} == '4'
  364.         OMAlert 'Identifier not found in CIncludes!'
  365.     Else
  366.         OMAlert "Unknown CIncludes error return value ({toolStatus})."
  367.     End
  368. End
  369.  
  370. # end of OMCIncludesTool